# clear environment
rm(list=ls())

# load packages
library(ggplot2)
library(openxlsx)

# load data set with crime numbers
dat = openxlsx::read.xlsx("vsberichte_metadata.xlsx", sheet = 1)

# only keep federal level crime numbers (remove federal states) since we want to plot Germany-wide trends
bund <- dat[dat$jurisdiction=="bund",]

# keep relevant variables
bund = bund[,c("year", "extreme_crime_right", "extreme_crime_left")]

# add 2024 numbers
bund_24 = c(2024, 37835, 5857)

bund = rbind.data.frame(bund, bund_24)

# create plot
ggplot(data=bund) + 
  geom_point(aes(x=year, y=extreme_crime_right, color="Right", shape="Right"), size=2.5) + 
  geom_line(aes(x=year, y=extreme_crime_right, color="Right")) +
  geom_point(aes(x=year, y=extreme_crime_left, color="Left", shape="Left"), size=2.5) + 
  geom_line(aes(x=year, y=extreme_crime_left, color="Left")) +
  xlab("") + ylab("Crimes") +
  theme_classic() +
  scale_color_manual(values=c("firebrick", "dodgerblue"), name="Type of Extremism", labels=c("LWE", "RWE")) +
  scale_shape_manual(values=c(16, 17), name="Type of Extremism", labels=c("LWE", "RWE")) +
  theme(legend.position = "bottom", text=element_text(size=18)) +
  scale_x_continuous(limits=c(1969, 2025)) +
  scale_y_continuous(breaks=seq(0, 40000, 10000), limits = c(0, 40000))

ggsave("Fig2_1.pdf", width=7, height=5)


